package com.sky.controller.admin;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sky.dto.PanoramaDTO;
import com.sky.entity.Inheritors;
import com.sky.entity.Panorama;
import com.sky.result.Result;
import com.sky.service.PanoramaService;
import io.swagger.annotations.Api;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/panorama")
@Api(tags = "管理端全景图相关接口")
public class PanoramaController {
    @Autowired
    private PanoramaService panoramaService;

    /**
     * 新增全景图
     */
    @PostMapping
    public Result<String> post(@RequestBody PanoramaDTO img) {
        Panorama panorama = new Panorama();
        BeanUtils.copyProperties(img, panorama);
        panoramaService.save(panorama);
        return Result.success();
    }

    /**
     * 删除全景图
     */
    @DeleteMapping
    public Result<String> delete(@RequestParam List<String> ids) {
        panoramaService.removeByIds(ids);
        return Result.success();
    }

    /**
     * 根据非遗id查询全景图
     */
    @GetMapping("/{id}")
    public Result<List<Panorama>> get(@PathVariable Integer id) {
        return Result.success(panoramaService.getByNonheritage(id));
    }
}
